<?php

class JuncaoDao extends BaseDao {
	
	public function __construct($dsn, $username, $password) {
		parent::__construct($dsn, $username, $password);
			
		$this->mapping = new Mapping("JuncaoModel", "t_dom_juncao", "id",
		array(
			"id",
			"descricao"
		),
		array(
			"id_juncao",
			"descricao_juncao"
		));
	}

	public function findByName($name) {
		$mappingInfo = $this->mapping->getMappingInfo();
		$columnName = $mappingInfo["nome"];
		$tableName = $this->mapping->getTableName();
			
		$query = "SELECT * FROM " . $tableName . " WHERE " . $columnName . "=:name;";
		
		$pdo = $this->dataSource->getPdo();
		$statement = $pdo->prepare($query);
		$statement->execute(array("name" => $name));
		$result = $statement->fetch(PDO::FETCH_ASSOC);
			
		$user = null;

		if ($result) {
			$user = $this->makeObject($result);
		}
			
		return $user;
	}
}
?>